/**
 * 公司成交统计
 * - 使用自定义封装组件，简化代码，统一管理。
 * - 2025-07-11 16:46:36 tzj
 * */

import BaseComponent from "../../components/BaseComponent";
import {mrhzApi} from "../../services/basic";
import Dictionary from "../../services/dictionary";

// 要显示的form表单
const formItemList =
    [
        "companies",
        "serviceWx2",
        {
            name: 'personZw',
            keyword: 'dg',
            label: '导购',
            zw: '3'
        },
        {
            name: 'chooseDateRange',
            label: '审核日期'
        }
    ];
// 显示的按钮
const buttons = ["query", "export",];
// 表格列信息
const columns = [
    {
        title: '公司名称',
        dataIndex: 'gsmc',
        key: 'gsmc',
        width: "20%",
        sumName: "合计",
    },
    {
        title: '总到店',
        tip: "到店已成交+到店未成交",
        // dataIndex: '',
        render: (_, record) => Number(record.ddwcj) + Number(record.ddycj),
        formula: "=SUM({{ddwcj}},{{ddycj}})",
        sorter: true
    },
    {
        title: '到店未成交',
        dataIndex: 'ddwcj',
        sorter: true
    },
    {
        title: '到店已成交',
        dataIndex: 'ddycj',
        sorter: true
    },
    {
        title: '异公司到店',
        dataIndex: 'ygsdd',
        sorter: true
    },
    {
        title: '异公司成交',
        dataIndex: 'ygscj',
        sorter: true
    },
    {
        title: '总金额',
        dataIndex: 'cjje',
        sorter: true
    },
    {
        title: '总单价',
        dataIndex: 'zdj',
        sorter: true
    },
    {
        title: '成交率（%）',
        dataIndex: 'wxcjl',
        sorter: true,
        sumName: ""
    },
    {
        title: '客单价',
        dataIndex: 'wxkdj',
        sorter: true,
        sumName: ""
    },
]

class pageGscjtj extends BaseComponent {
    constructor(props) {
        super(props);
        this.state = {
            ...this.state,
            formItemList,
            buttons,
            // columns,
            filename: "公司成交统计",
            queryAll: true,
            sumRow: true,
        }
        this.columns = columns;
        this.queryApi = mrhzApi.getPagegsxq;
        this.hasLzModal = true;
    }

    onRowDoubleClick = (record) => {
        const params = {
            // ...this.form.dataForm,
            jzqsrq: this.form.dataForm.cjqsrq,
            jzzzrq: this.form.dataForm.cjzzrq,
            lxr: this.form.dataForm.lxr,
            dg: this.form.dataForm.dg,
            yybm: record.yybm,
        }

        const config = {
            queryApi: mrhzApi.selectPagecj,
            columns: Dictionary.dealColumns,
            tableTitle: "成交详情",
            // width: 1200
        }
        this.lzModalRef.open(params, config);
    }
}

export default pageGscjtj;